package d7_homework.d3_homeworkday06.d2_secondquestion;


import java.util.ArrayList;
import java.util.Collections;

public class Test {
    public static void main(String[] args) {
        //1、创建一个集合,用于存储每一个学生
        ArrayList<Student> students = new ArrayList<>();
        //往集合中添加学生对象
        Collections.addAll(students,
                new Student(1, "陈平安", "骊珠洞天"),
                new Student(2, "宁姚", "剑气长城"),
                new Student(3, "姬紫月", "姬家"),
                new Student(4, "叶凡", "地球"));

        //遍历集合将每个学生的姓名拿出来
        for (Student student : students) {
            //判断如果是叶凡,就改成姬家
            if (student.getName().equals("叶凡")){
                student.setAddress("姬家");
            }
        }
        //遍历结合获取属性
        students.forEach(System.out::println);

    }
}
